package com.czk.bootlettuce.reentrantredislock;

import java.util.concurrent.TimeUnit;

/**
 * @author chenzhangkun
 * @ClassName Lock
 * @description: TODO
 * @date 2024年02月01日
 */
public interface Lock {
    /***
     * 阻塞等待 waitTime时间尝试获取锁
     *
     * @author chenzhangkun
     * @date 2024/2/1 9:40
     * @param    waitTime
     * @param    leaseTime
     * @param    unit
     * @return boolean
     * @throws InterruptedException
     **/
    boolean tryLock(long waitTime, long leaseTime, TimeUnit unit) throws InterruptedException;

    /***
     *  一直尝试自旋阻塞等待获取分布式锁，直到获取成功为止
     *
     * @author chenzhangkun
     * @date 2024/2/1 9:40
     * @param    leaseTime
     * @param    unit
     * @return void
     **/
    void lock(long leaseTime, TimeUnit unit);

    /***
     * 解锁接口
     *
     * @author chenzhangkun
     * @date 2024/2/1 10:02
     * @param
     * @return void
     **/
    void unLock();
}
